// script.js
const SUITS = ['♠', '♥', '♦', '♣'];
const RANKS = ['3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', '2'];
const CARDS = RANKS.flatMap(rank => SUITS.map(suit => rank + suit));

let hands = {
    player1: [],
    player2: [],
    player3: []
};

// 发牌函数
function dealCards() {
    const shuffledCards = [...CARDS].sort(() => Math.random() - 0.5);
    hands.player1 = shuffledCards.slice(0, 17);
    hands.player2 = shuffledCards.slice(17, 34);
    hands.player3 = shuffledCards.slice(34, 51);

    renderHands();
}

// 渲染手牌
function renderHands() {
    for (const player in hands) {
        const handElement = document.querySelector(`#${player} .hand`);
        handElement.innerHTML = hands[player].map(card => `<div class="card">${card}</div>`).join('');
    }
}

// 出牌函数
function playCard(player) {
    if (hands[player].length > 0) {
        const card = hands[player].pop(); // 简单模拟出牌（每次出最后一张）
        alert(`${player} 出牌: ${card}`);
        renderHands();
    } else {
        alert(`${player} 没有牌了！`);
    }
}

// 初始化
dealCards();
